package com.itlin.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itlin.bean.DishFlavor;
import com.itlin.dao.DishFlavorDao;
import com.itlin.dto.DishDto;
import com.itlin.service.DishFlavorService;
import com.itlin.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 所谓伊人
 * @date 2022/3/25 - 15:40
 */
@Transactional
@Service
public class DishFlaoverServiceImpl implements DishFlavorService {

    @Autowired
    private DishFlavorDao dao;

    @Override
    public int add(DishFlavor dishFlavor) {
        return dao.insert(dishFlavor);
    }

    @Override
    public List<DishFlavor> findByDishId(long id) {

        LambdaQueryWrapper<DishFlavor> qw = new LambdaQueryWrapper<>();

        qw.eq(DishFlavor::getDishId,id);

        return dao.selectList(qw);
    }

    @Override
    public int deleteByDishId(long dishId) {

        LambdaQueryWrapper<DishFlavor> qw = new LambdaQueryWrapper<>();

        qw.eq(DishFlavor::getDishId,dishId);
        return dao.delete(qw);
    }

}
